package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadFile {

	/**
	 * @param args
	 */
	private static final String SPLIT = "\u0001";
	private static final String SPLIT2 = "\010";
	private static final String SPLIT3= "\t";
	
	public static String handleSplit(String s){
		s = s.replaceAll("\u0001{2,}", "\u0001");
		s = s.replaceAll("\u0001$", "");
		s = s.replaceAll("\t", " ");
		return s;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String filename=args[0];
		String split=SPLIT;
		System.out.println("aa"+args[0]+"bb");
		System.out.println("aa\tbb");
		System.out.println("aa"+SPLIT+"bb");
		int count=1;
		File file = new File(filename);
		try {
			BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
			String line=null;
			try {
				while((line = in.readLine()) != null){
					
					String[] len=handleSplit(line).split(split);
					if(count==1){
						System.out.println(len.length);
						for(int i=0;i<len.length;i++){
							System.out.println(len[i]);
						}
						System.out.println("=====");
						count++;
					}
					
//					if(len[5]=="100002192" || len[4]=="100002192"){
					if(len[5].equalsIgnoreCase("128113406") || len[4].equalsIgnoreCase("128113406")
							|| len[3].equalsIgnoreCase("128113406")){
					System.out.println(len.length);
					for(int i=0;i<len.length;i++){
						int k=len[i].indexOf(SPLIT3);
						if(k>-1){
							System.out.println("---"+len[i]);
						}
						System.out.println(len[i]);
					}
					System.out.println("=====");
					}
					
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
